<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3_5_1-1-内联绑定class属性</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

  <style>
    .red {
      color: red;
      font-size: 2em;
    }

    .blue {
      color: blue;
    }
  </style>

  <div id="app">
    <h1>内联对象</h1>
    <div :class="{blue:isBlue,red:isRed}">示例文案</div>
    <button @click="btn">改变样式{{ isBlue ? "为红" : "为蓝" }}</button>
  </div>

  <script>
    const App = {
      data() {
        return {
          //内联对象
          isBlue: true,
          isRed: false,
          //作为数据对象
        };
      },
      methods: {
        btn() {
          (this.isBlue = !this.isBlue), (this.isRed = !this.isRed);
        },
      },
    };
    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>